//
//  VCRegisterComplete.m
//  express
//
//  Created by mac1 on 15/9/21.
//  Copyright (c) 2015年 longchen. All rights reserved.
//

#import "VCRegisterComplete.h"
#import "Masonry.h"


@interface VCRegisterComplete ()<UITextFieldDelegate>

@property (nonatomic, strong) UIView * viewTopContainer;

@end

@implementation VCRegisterComplete

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor lightGrayColor];
    
    [self addNavigation];
    
    [self addCtrls];
    // Do any additional setup after loading the view.
}


-(void)addCtrls
{
    //添加上部分的容器
    self.viewTopContainer  = [[UIView alloc]init];

    [self.view   addSubview:self.viewTopContainer];

    //self.viewTopContainer.backgroundColor = [UIColor grayColor];

    [self.viewTopContainer mas_makeConstraints:^(MASConstraintMaker *make) {

        make.centerX.mas_equalTo(self.view.mas_centerX);

        make.top.mas_equalTo(self.view.mas_top).offset(self.view.height/10);

        make.width.mas_equalTo(self.view.mas_width);

        make.height.mas_equalTo(self.view.height/2);

    }];


    //快递工号小标题
    UILabel * lbDeliveryNum = [[UILabel alloc]init];
    
    [self.viewTopContainer addSubview:lbDeliveryNum];
    
    lbDeliveryNum.text = @"快递工号";
    
    [lbDeliveryNum mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.centerX.mas_equalTo(self.viewTopContainer.mas_centerX);
        
        make.top.mas_equalTo(self.viewTopContainer.mas_top).offset(10);
        
        make.width.mas_equalTo(self.viewTopContainer.width);
        
        make.height.mas_equalTo(30);
    }];
    
    
    //账号输入框
    UITextField * tfDeliveryNum = [[UITextField alloc]init];
    
    [self.viewTopContainer addSubview:tfDeliveryNum ];
    
    tfDeliveryNum.delegate = self;
    
    tfDeliveryNum .borderStyle = UITextBorderStyleNone;
    
    tfDeliveryNum .placeholder = @"请输入您工号";
    
    tfDeliveryNum .textAlignment = NSTextAlignmentCenter;
    
    [tfDeliveryNum  mas_makeConstraints:^(MASConstraintMaker *make)
     {
         
         make.centerX.mas_equalTo(self.viewTopContainer.mas_centerX);
         
         make.top.mas_equalTo(lbDeliveryNum.mas_bottom).offset(20);
         
         make.width.mas_equalTo(180);
         
         make.height.mas_equalTo(30);
         
     }];
    
    
      //工号输入框下划线
    UIImageView *ivBottomLine = [[UIImageView alloc]init];
    
    [self.viewTopContainer addSubview:ivBottomLine];
    
    ivBottomLine.backgroundColor = [UIColor grayColor];
    
    [ivBottomLine mas_makeConstraints:^(MASConstraintMaker *make)
     {

         make.centerX.mas_equalTo(self.viewTopContainer.mas_centerX);

         make.top.mas_equalTo(tfDeliveryNum .mas_bottom).offset(1);

         make.width.mas_equalTo(tfDeliveryNum .mas_width);

         make.height.mas_equalTo(1);

     }];


    //描述
    UILabel * lbDescription = [[UILabel alloc]init];
    
    [self.viewTopContainer addSubview:lbDescription];
    
    lbDescription.text = @"如您是申通、圆通、中通、百世汇通和韵达旗下的快递员师傅，请绑定您的快递工号，可获得首次绑定奖励~";
    
    lbDescription.font = [UIFont systemFontOfSize:12];
    
    lbDescription.numberOfLines = 0;
    
    [lbDescription mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(self.viewTopContainer.mas_centerX);
        
        make.top.mas_equalTo(ivBottomLine.mas_bottom).offset(20);
        
        make.width.mas_equalTo(ivBottomLine.mas_width);
        
        make.height.mas_equalTo(80);
        
    }];
    
    
    //完成按钮
    UIButton* btnComplete = [UIButton buttonWithType:UIButtonTypeSystem];
    
    [self.viewTopContainer addSubview:btnComplete];
    
    [btnComplete addTarget:self action:@selector(btnComplete:) forControlEvents:UIControlEventTouchDragInside];
    
    [btnComplete setTitle:@"完成" forState:UIControlStateNormal];
    
    btnComplete.titleLabel.font = [UIFont systemFontOfSize:16];
    
    [btnComplete setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    btnComplete.backgroundColor = [UIColor blueColor];
    
    [btnComplete mas_makeConstraints:^(MASConstraintMaker *make) {

        make.centerX.mas_equalTo(self.viewTopContainer.mas_centerX);

        make.top.mas_equalTo(lbDescription.mas_bottom).offset(20);

        make.width.mas_equalTo(120);

        make.height.mas_equalTo(30);

    }];
    
    
      //下划线
    UIImageView *ivBottomLineB = [[UIImageView alloc]init];
    
    [self.view addSubview:ivBottomLineB];
    
    ivBottomLineB.backgroundColor = [UIColor grayColor];
    
    [ivBottomLineB mas_makeConstraints:^(MASConstraintMaker *make)
     {

         make.centerX.mas_equalTo(self.view.mas_centerX);

         make.top.mas_equalTo(self.view.mas_bottom).offset(-50);

         make.width.mas_equalTo(self.view.width*0.8);

         make.height.mas_equalTo(2);

     }];

    
    //描述
    UILabel * lbJumpFst = [[UILabel alloc]init];
    
    [self.view addSubview:lbJumpFst];
    
    lbJumpFst.text = @"如果您是其他公司快递员可直接点击这里跳过此步骤";
    
    lbJumpFst.textAlignment = NSTextAlignmentCenter;
    
    lbJumpFst.font = [UIFont systemFontOfSize:12];
    
    lbJumpFst.numberOfLines = 0;
    
    [lbJumpFst mas_makeConstraints:^(MASConstraintMaker *make) {

        make.centerX.mas_equalTo(self.view.mas_centerX);

        make.top.mas_equalTo(ivBottomLineB.mas_bottom).offset(5);

        make.width.mas_equalTo(ivBottomLineB.mas_width);

        make.height.mas_equalTo(20);

    }];

}


-(void)btnComplete:(UIButton*)btnClick
{

    self.navigationController.navigationBarHidden = YES;

    [self.navigationController popToRootViewControllerAnimated:YES];

}


-(void)addNavigation
{
    
    //创建 标题LABEL
    UILabel * titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 60, 140, 30)];

    titleLabel.backgroundColor = [UIColor blackColor];

    titleLabel.text = @"注册完成";

    titleLabel.textAlignment = NSTextAlignmentCenter;

    //titleLabel.font = [UIFont systemFontOfSize:16];
    
    titleLabel.font = [UIFont boldSystemFontOfSize:20];//加粗
    
    titleLabel.textColor = [UIColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:1];
    
    self.navigationItem.titleView = titleLabel;
    
    
    //创建左侧按钮,这样写代码重用性较高
    UIButton *leftButton  = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 45, 25)];
    
    [leftButton addTarget:self action:@selector(rightBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    
    [leftButton setTitle:@"返回" forState:UIControlStateNormal];
    
    leftButton.titleLabel.font = [UIFont systemFontOfSize:14];
    
    UIBarButtonItem *leftBarButton = [[UIBarButtonItem alloc]initWithCustomView:leftButton];
    
    self.navigationItem.leftBarButtonItem = leftBarButton;

    //设置模糊,默认YES
    //[self.navigationController.navigationBar setTranslucent:NO];

}


-(void)rightBtnClick:(UIButton*)leftButton
{
    
    [self.navigationController popViewControllerAnimated:YES];
    
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    
    // Dispose of any resources that can be recreated.
}


-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    
    [textField resignFirstResponder];
    
    return YES;
    
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
